import { fetchManHourLists, fetchManHourDetail } from '../../fetch/modules/manHourSelect'

const state = {
   manHourLists: {},
   manHourDetail: {}
}

const actions = {
    GET_MANHOUR_LISTS: ({ commit, state }, opt) => {
        return fetchManHourLists(opt).then(manhour => commit('FETCH_MANHOUR_LISTS', { manhour }))
    },
    GET_MANHOUR_DETAIL: ({ commit, state }, opt) => {
        return fetchManHourDetail(opt).then(manhour => commit('FETCH_MANHOUR_DETAIL_BYID', { manhour }))
    }
}
const mutations = {
    FETCH_MANHOUR_LISTS: (state, { manhour }) => {
        state.manHourLists = manhour.data;
    },
    FETCH_MANHOUR_DETAIL_BYID: (state, { manhour }) => {
        state.manHourDetail = manhour.data;
    }
}

const getters = {
    getManHourLists(state) {
        return state.manHourLists;
    },
    getManHourDetail(state) {
        return state.manHourDetail;
    }
}

export default {
    state,
    actions,
    mutations,
    getters
}